package edu.xust.controller.content;

import edu.xust.dto.AdDto;
import edu.xust.service.AdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 广告类
 */
@Controller
@RequestMapping("/ad")
public class AdController {
    @Autowired
    AdService adService;
    @RequestMapping
    public String init(){
        return "/content/adList";
    }

    /**
     * 模糊查询广告条目
     * @param adDto
     */
    @RequestMapping("/search")
    public String search(Model model, AdDto adDto){
      model.addAttribute("list",adService.searchByPage(adDto));
        return "content/adList";
    }
//删除
    @RequestMapping("/remove")
    public String remove(@RequestParam("id") Integer id,AdDto adDto){
        adService.remove(adDto);
        return "content/adList";
    }
//修改
    @RequestMapping("/modifyInit")
    public boolean modify(@RequestParam("id") Integer id,AdDto adDto ){
        adService.update(adDto);
        return false;
    }
}
